<!--
 *  Copyright (c) 2021 GraphQL Contributors
 *  All rights reserved.
 *
 *  This source code is licensed under the license found in the
 *  LICENSE file in the root directory of this source tree.
-->
<!DOCTYPE html>
<html>
<head>
  <title>OpenSearchServer console</title>
  <meta charset="utf-8">
  <style>
    body {
      height: 100%;
      margin: 0;
      width: 100%;
      overflow: hidden;
    }

    #graphiql {
      height: 100vh;
    }
  </style>
  <!--
    This GraphiQL example depends on Promise and fetch, which are available in
    modern browsers, but can be "polyfilled" for older browsers.
    GraphiQL itself depends on React DOM.
    If you do not want to rely on a CDN, you can host these files locally or
    include them directly in your favored resource bunder.
  -->
  <script src="/webjars/react/16.14.0/umd/react.production.min.js"></script>
  <script src="/webjars/react-dom/16.14.0/umd/react-dom.production.min.js"></script>

  <!--
    These two files can be found in the npm module, however you may wish to
    copy them directly into your environment, or perhaps include them in your
    favored resource bundler.
   -->
  <link rel="stylesheet" href="/webjars/graphiql/1.4.2/graphiql.css"/>
</head>

<body>
<div id="graphiql">Loading...</div>
<script
  src="/webjars/graphiql/1.4.2/graphiql.min.js"
  type="application/javascript"
></script>
<script>
  function graphQLFetcher(graphQLParams) {
    return fetch(
      'http://localhost:9090/graphql',
      {
        method: 'post',
        headers: {
          Accept: 'application/json',
          'Content-Type': 'application/json',
        },
        body: JSON.stringify(graphQLParams),
        credentials: 'omit',
      },
    ).then(function (response) {
      return response.json().catch(function () {
        return response.text();
      });
    });
  }

  ReactDOM.render(
    React.createElement(GraphiQL, {
      fetcher: graphQLFetcher,
      defaultVariableEditorOpen: true,
    }),
    document.getElementById('graphiql'),
  );
</script>
</body>
</html>
